package com.ruoyi.webshop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.webshop.domain.GoodsSafeguardType;
import com.ruoyi.webshop.service.IGoodsSafeguardTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 增值保障Controller
 * 
 * @author ruoyi
 * @date 2024-03-17
 */
@RestController
@RequestMapping("/webshop/GoodsSafeguardType")
public class GoodsSafeguardTypeController extends BaseController
{
    @Autowired
    private IGoodsSafeguardTypeService goodsSafeguardTypeService;

    /**
     * 查询增值保障列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsSafeguardType goodsSafeguardType)
    {
        startPage();
        List<GoodsSafeguardType> list = goodsSafeguardTypeService.selectGoodsSafeguardTypeList(goodsSafeguardType);
        return getDataTable(list);
    }

    /**
     * 导出增值保障列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:export')")
    @Log(title = "增值保障", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsSafeguardType goodsSafeguardType)
    {
        List<GoodsSafeguardType> list = goodsSafeguardTypeService.selectGoodsSafeguardTypeList(goodsSafeguardType);
        ExcelUtil<GoodsSafeguardType> util = new ExcelUtil<GoodsSafeguardType>(GoodsSafeguardType.class);
        util.exportExcel(response, list, "增值保障数据");
    }

    /**
     * 获取增值保障详细信息
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:query')")
    @GetMapping(value = "/{safeguardTypeId}")
    public AjaxResult getInfo(@PathVariable("safeguardTypeId") Long safeguardTypeId)
    {
        return success(goodsSafeguardTypeService.selectGoodsSafeguardTypeBySafeguardTypeId(safeguardTypeId));
    }

    /**
     * 新增增值保障
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:add')")
    @Log(title = "增值保障", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsSafeguardType goodsSafeguardType)
    {
        return toAjax(goodsSafeguardTypeService.insertGoodsSafeguardType(goodsSafeguardType));
    }

    /**
     * 修改增值保障
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:edit')")
    @Log(title = "增值保障", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsSafeguardType goodsSafeguardType)
    {
        return toAjax(goodsSafeguardTypeService.updateGoodsSafeguardType(goodsSafeguardType));
    }

    /**
     * 删除增值保障
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsSafeguardType:remove')")
    @Log(title = "增值保障", businessType = BusinessType.DELETE)
	@DeleteMapping("/{safeguardTypeIds}")
    public AjaxResult remove(@PathVariable Long[] safeguardTypeIds)
    {
        return toAjax(goodsSafeguardTypeService.deleteGoodsSafeguardTypeBySafeguardTypeIds(safeguardTypeIds));
    }
}
